package com.itheima.wms.config;

import java.sql.*;

public class InsertCloumeName {
    public static void main(String[] args) throws Exception {
        createObject();
    }


    public static void createObject() throws Exception {
        String table = "wms_location";
        StringBuilder sb = new StringBuilder();
        Class.forName("com.mysql.cj.jdbc.Driver");
        String url = "jdbc:mysql://127.0.0.1:3306/yf-wms?serverTimezone=Asia/Shanghai&useUnicode=true&allowPublicKeyRetrieval=true&characterEncoding=utf8&useSSL=false&zeroDateTimeBehavior=CONVERT_TO_NULL&autoReconnect=true&allowMultiQueries=true";
        Connection connection = DriverManager.getConnection(url, "root", "1234");
        String sql = "select *  from  " + table + " limit 1,1";
        PreparedStatement ps = connection.prepareStatement(sql);
        ResultSet resultSet = ps.executeQuery();
        ResultSetMetaData metaData = resultSet.getMetaData();
        int columnCount = metaData.getColumnCount();
        for (int i = 1; i <= columnCount; i++) {
            String propName = metaData.getColumnName(i);
            String cloumeName = propName;
            if (propName.contains("_")) {
                String[] split = propName.split("_");
                propName = split[0];
                for (int i1 = 1; i1 < split.length; i1++) {
                    propName += split[i1].substring(0, 1).toUpperCase() + split[i1].substring(1);
                }
            }
            sb.append("#{").append(propName).append("},").append("\n");
        }

        System.out.println(sb);

    }
}